from typing import Dict, List
from models.character import Character

class CharacterFactory:
    """角色工厂 - 创建和管理播客角色"""
    
    def __init__(self):
        self.characters: Dict[str, Character] = {}
    
    def create_character(self, name: str, personality: str, role: str) -> Character:
        """创建单个角色"""
        character = Character(name=name, personality=personality, role=role)
        self.characters[name] = character
        return character
    
    def create_multiple_characters(self, character_configs: List[Dict]) -> List[Character]:
        """批量创建角色"""
        characters = []
        for config in character_configs:
            character = self.create_character(
                config['name'], 
                config['personality'], 
                config['role']
            )
            characters.append(character)
        return characters
    
    def get_character(self, name: str) -> Character:
        """获取角色"""
        return self.characters.get(name)
    
    def list_characters(self) -> List[Character]:
        """列出所有角色"""
        return list(self.characters.values())